<!--
 * @Date: 2021-09-02 17:21:31
 * @Author: 陶子
 * @LastEditTime: 2023-06-15 15:56:04
 * @FilePath: \jk_one-stop_pc\src\views\bigView\production\components\productionInfo.vue
 * @pageName: 这是--（生产大屏信息）--组件
-->
<template>
  <div class="numberRoot">
    <div class="topBox">
      <img src="~@/assets/img/screen-p1.png" alt="" />
      <div class="topOne">日生产总量</div>
      <div
        class="topTwo"
        v-if="infoObj.percentage && infoObj.percentage != 0"
        :style="{ color: infoObj.percentage > 0 ? '#1AD995' : '#F32144' }"
      >
        较昨日{{ infoObj.percentage > 0 ? '增长' : '下降'
        }}{{ infoObj.percentage > 0 ? infoObj.percentage : -infoObj.percentage }}%
      </div>
      <div class="topTwo" v-else>较昨日无变化</div>
    </div>
    <div class="middleBox">
      <!-- <div class="itemMBox" v-for="(item,index) in nowDayNum" :key="index">{{item}}</div> -->
      <div class="itemMBox">{{ nowDayNum[0] }}</div>
      <div class="comma">,</div>
      <div class="itemMBox">{{ nowDayNum[1] }}</div>
      <div class="itemMBox">{{ nowDayNum[2] }}</div>
      <div class="itemMBox">{{ nowDayNum[3] }}</div>
      <div class="comma">,</div>
      <div class="itemMBox">{{ nowDayNum[4] }}</div>
      <div class="itemMBox">{{ nowDayNum[5] }}</div>
      <div class="itemMBox">{{ nowDayNum[6] }}</div>
      <div class="comma">.</div>
      <div class="itemMBox">{{ nowDayNum[7] }}</div>
      <div class="itemMBox">{{ nowDayNum[8] }}</div>
    </div>
    <div class="lastBox">
      <div class="lastTop">
        <div class="lastItemBox">
          <div class="itemRight_bot">{{ numFormat(infoObj.planProduceNum) }}</div>
          <div class="itemRight_top">计划生产(生产中)</div>
          <img src="~@/assets/img/screenicon1.png" alt="" />
        </div>
        <div class="lastItemBox">
          <div class="itemRight_bot">{{ numFormat(infoObj.qualifiedNum) }}</div>
          <div class="itemRight_top">已生产数(生产中)</div>
          <img src="~@/assets/img/screenicon2.png" alt="" />
        </div>
        <div class="lastItemBox">
          <div class="itemRight_bot">{{ numFormat(infoObj.orderNum) }}</div>
          <div class="itemRight_top">工单数(生产中)</div>
          <img src="~@/assets/img/screenicon3.png" alt="" />
        </div>
      </div>
      <div class="lastTop" style="margin-bottom: -0.2rem">
        <div class="lastItemBox">
          <div class="itemRight_bot">{{ numFormat(infoObj.overdueNum) }}</div>
          <div class="itemRight_top">工单逾期数</div>
          <img src="~@/assets/img/screenicon4.png" alt="" />
        </div>
        <div class="lastItemBox">
          <div class="itemRight_bot">{{ numFormat(infoObj.completedTodayNum) }}</div>
          <div class="itemRight_top">完成工单数(今日)</div>
          <img src="~@/assets/img/screenicon5.png" alt="" />
        </div>
        <div class="lastItemBox">
          <div class="itemRight_bot">{{ infoObj.failureTodayRate }}%</div>
          <div class="itemRight_top">不合格率(今日)</div>
          <img src="~@/assets/img/screenicon6.png" alt="" />
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import { numFormat } from '@/utils/util'
export default {
  name: 'productionInfo',
  props: ['infoData'],
  data() {
    return {
      numFormat,
      infoObj: {},
      nowDayNum: [],
    }
  },

  watch: {
    infoData: {
      handler(newVal, oldVal) {
        this.infoObj = newVal
        if (newVal.nowDayNum) {
          let strArr = String(newVal.nowDayNum).split('.')
          let firstArr = strArr[0]
          let lastArr = strArr[1]
          let allStr = ''
          if (firstArr.length < 7) {
            let currentLength = firstArr.length
            let addLength = 7 - currentLength
            for (let i = 0; i < addLength; i++) {
              firstArr = '0' + firstArr
            }
            if (!lastArr) {
              lastArr = '00'
            }
            allStr = firstArr + '' + lastArr
          } else {
            allStr = '999999999'
          }
          this.nowDayNum = allStr.split('')
        } else {
          this.nowDayNum = [0, 0, 0, 0, 0, 0, 0, 0, 0]
        }
      },
      deep: true,
      immediate: true,
    },
  },
  mounted() {},
  methods: {},
}
</script>

<style scoped lang="less">
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.numberRoot {
  width: 100%;
  height: 100%;
  color: #fff;
  div.topBox {
    .flex(flex-start,center);
    margin-bottom: 0.14rem;
    padding-top: 0.4rem;
    div.topOne {
      font-size: 0.18rem;
      color: #ffffff;
      margin-right: 0.28rem;
      font-family: Microsoft YaHei;
      font-weight: bold;
    }

    div.topTwo {
      font-size: 0.2rem;
      color: #3fbffb;
    }
    img {
      width: 0.53rem;
      height: 0.52rem;
    }
  }

  div.middleBox {
    .flex(space-between,center);
    margin-bottom: 0.16rem;
    .itemMBox {
      .flex(center,center);
      background-image: url('~@/assets/img/screen-p7.png');
      background-size: 100% 100%;
      background-position: center center;
      width: 0.76rem;
      height: 0.97rem;
      font-size: 0.5rem;
      font-weight: bold;
      font-family: DS-Digital;
      color: #fff;
    }
    .comma {
      font-size: 0.7rem;
      color: rgba(216, 250, 255, 0.9);
      position: relative;
      top: 0.1rem;
    }
  }

  div.lastBox {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 3.13rem;
    padding: 0 0.5rem;
    .lastTop {
      .flex(space-between,center);
    }
    div.lastItemBox {
      width: 1.8rem;
      height: 1.5rem;
      background: url('~@/assets/img/screen-p8.png') no-repeat;
      background-size: 100% 100%;
      background-position: center center;
      text-align: center;
      .itemRight_bot {
        font-size: 0.22rem;
        font-family: Alimama ShuHeiTi;
        font-weight: bold;
        color: #23fffc;
        margin-bottom: -0.2rem;
      }
      .itemRight_top {
        font-size: 0.13rem;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ccd6d6;
        padding-top: 0.15rem;
      }
      img {
        width: 0.48rem;
        height: 0.48rem;
        margin-top: 0.1rem;
      }
    }
  }
}
</style>
